import { createRouter, createWebHistory } from 'vue-router';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';

import { appRoutes } from './routes';
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';
import createRouteGuard from './guard';
import {  qiankunWindow,} from "vite-plugin-qiankun/dist/helper";

NProgress.configure({ showSpinner: false }); // NProgress Configuration
// const status = (qiankunWindow && qiankunWindow.__POWERED_BY_QIANKUN__) 
// history: createWebHistory(status ? `/saas-management/service/` : "/"),
 const route = createRouter({
  history: createWebHistory("/saas-service/"),
  routes: [
    {
      path: '/',
      redirect: 'login',
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
      meta: {
        requiresAuth: false,
      },
    },
    ...appRoutes,
    REDIRECT_MAIN,
    NOT_FOUND_ROUTE,
  ],
  scrollBehavior() {
    return { top: 0 };
  },
});

// !status && createRouteGuard(route);
// export const routes = [
//   {
//     path: '/',
//     redirect: 'login',
//   },
//   {
//     path: '/login',
//     name: 'login',
//     component: () => import('@/views/login/index.vue'),
//     meta: {
//       requiresAuth: false,
//     },
//   },
//   ...appRoutes,
//   REDIRECT_MAIN,
//   NOT_FOUND_ROUTE,
// ]
export default route;